package analisis.matrizContingencia;

import java.util.List;

/**
 * @file Specificity.java
 * @author Juan Humanes Ferrer
 * @date 14-Marzo-2014
 *
 */
public final class Specificity implements IMedida {

    private double specificity;//valor en porcentaje

    public Specificity() {
        setSpecificity(0.0);//valor en porcentaje
    }

    /**
     * Método que retorna el specificity
     *
     * @return specificity
     */
    public double getSpecificity() {
        return specificity;
    }

    /**
     * Métodod que modifica el valor de specificity
     *
     * @param specificity
     */
    public void setSpecificity(double specificity) {
        this.specificity = specificity;
    }

    /**
     * Método que calcula la Specificity
     *
     * @param tp
     * @param tn
     * @param fp
     * @param fn
     * @param valoresMedidas
     */
    @Override
    public void calculaMedida(double tp, double tn, double fp, double fn, List<IMedida> valoresMedidas) {

        double result = Double.POSITIVE_INFINITY;

        if (tn != 0.0 && fp != 0.0) {
            result = tn / (fp + tn);
            result *= 100.0;
        }

        setSpecificity(result);
    }

    @Override
    public Double verValor() {
        return getSpecificity();
    }

}
